<?php
declare (strict_types = 1);

namespace app\model;

use think\Model;

/**
 * @mixin \think\Model
 */
class ChargeRecord extends Model
{
    protected $autoWriteTimestamp = 'datetime';
    
    // 设置当前模型对应的完整数据表名称
    protected $table = 'charge_record';

    // 设置字段信息
    protected $schema = [
        'payment_id'                    => 'integer',
        'user_id'                       => 'integer',
        'amount'                        => 'float',
        'pay_amount'                    => 'float',
        'success_amount'                => 'float',
        'shop_order'                    => 'string',
        'platform_order'                => 'string',
        'acquirer_order'                => 'string',
        'describe'                      => 'string',
        'ip'                            => 'string',
        'client_type'                   => 'integer',
        'order_status'                  => 'integer',
        'pay_status'                    => 'boolean',
        'notice_status'                 => 'boolean',
        'notice_number'                 => 'integer',
        'card_no'                       => 'string',
        'card_key'                      => 'string',
        'extend'                        => 'string',
        'create_time'                   => 'datetime',
        'update_time'                   => 'datetime'
    ];

    // 设置字段自动转换类型
    protected $type = [
        'update_time'       => 'datetime',
        'create_time'       => 'datetime',
        'order_status'      => 'integer',
    ];

    public function roles()
    {
        return $this->belongsToMany(ShopsPayments::class, 'access');
    }
}
